package com.mdd.mapper;

import com.mdd.domain.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface UserMapper {

    // 新增用户
    @Insert("insert into users(id, user_name, password) value(null,#{userName},#{password})")
    Integer addUser(User user);

    // 查询所有
    @Select("select id, user_name userName, password from users")
    List<User> selectAll();

    // 根据ID查询
    @Select("select id, user_name userName, password from users where id = #{id}")
    User selectById(int id);

    // 根据ID修改
    @Update("update users set user_name = #{userName},password = #{password} where id = #{id}")
    Integer updateById(User user);

    // 根据ID删除
    @Delete("delete from users where id = #{id}")
    Integer deleteById(int id);

}
